<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>

    <div id="root">
        
    </div>


    <script type="text/javascript">
         Vue.config.productionTip = false;//阻止vue在启动的时候生成生产提示

         //创建student组件
        const student = Vue.extend({
            template:`
            <div>
                <h2>学生姓名：{{name}}</h2>
                <h2>学生年龄：{{age}}</h2>
            </div>
            `,
            data(){
                return{
                    name:'张扬',
                    age:22
                }
            }
        })

        //创建student组件
        const hello = Vue.extend({
            template:`
            <div>
                <h2>{{hello}}</h2>
            </div>
            `,
            data(){
                return{
                    hello:'你好！'
                }
            }
        })

         //创建school组件
        const school = Vue.extend({
            //组件不要写el配置项，因为所有组件都由vm管理，由vm决定应该服务哪个容器
            template:`
                <div>
                    <h2>学校名称：{{schoolName}}</h2>
                    <h2>学校地址：{{schoolAddress}}</h2>
                    <student></student>
                </div>
            `,
            data(){
                return{
                    schoolName:'中南民族大学',
                    schoolAddress:'民族大道关山街道'
                }
            },
            //局部注册组件
            components:{
                student:student
            }
        })

        //标准化开发需要全部装入app组件
        const app = Vue.extend({
            template:`
                <div>
                    <hello></hello>
                    <school></school>    
                </div>
            `,
            components:{
                hello:hello,
                school:school
            }
        })

        const vm = new Vue({
            template:`
                <app></app>
            `,
            el:"#root",
            data:{
                hello:"你好啊！"
            },

            //注册组件(局部注册)
            components:{
                app
            }
         })
    </script>
</body>
</html>